<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Time.Clock.Internal.CTimeval</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#ifndef mingw32_HOST_OS
</span><span class="hs-comment">-- All Unix-specific, this</span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &gt;= 709
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Safe</span><span class="hs-cpp">
#endif
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.C</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">CTimeval</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">MkCTimeval</span><span> </span><span class="hs-identifier">CLong</span><span> </span><span class="hs-identifier">CLong</span><span>
</span><span id="line-14"></span><span>
</span><span id="line-15"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Storable</span><span> </span><span class="hs-identifier">CTimeval</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-16"></span><span>    </span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">undefined</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CLong</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-operator">*</span><span> </span><span class="hs-number">2</span><span>
</span><span id="line-17"></span><span>    </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">undefined</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CLong</span><span class="hs-special">)</span><span>
</span><span id="line-18"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-19"></span><span>        </span><span class="hs-identifier">s</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peekElemOff</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">p</span><span class="hs-special">)</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-20"></span><span>        </span><span class="hs-identifier">mus</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peekElemOff</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">p</span><span class="hs-special">)</span><span> </span><span class="hs-number">1</span><span>
</span><span id="line-21"></span><span>        </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">MkCTimeval</span><span> </span><span class="hs-identifier">s</span><span> </span><span class="hs-identifier">mus</span><span class="hs-special">)</span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">MkCTimeval</span><span> </span><span class="hs-identifier">s</span><span> </span><span class="hs-identifier">mus</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-23"></span><span>        </span><span class="hs-identifier">pokeElemOff</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">p</span><span class="hs-special">)</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-identifier">s</span><span>
</span><span id="line-24"></span><span>        </span><span class="hs-identifier">pokeElemOff</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">p</span><span class="hs-special">)</span><span> </span><span class="hs-number">1</span><span> </span><span class="hs-identifier">mus</span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">ccall</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;time.h gettimeofday&quot;</span><span> </span><span class="hs-identifier">gettimeofday</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">CTimeval</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CInt</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-comment">-- | Get the current POSIX time from the system clock.</span><span>
</span><span id="line-29"></span><span class="hs-identifier">getCTimeval</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">CTimeval</span><span>
</span><span id="line-30"></span><span class="hs-identifier">getCTimeval</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">with</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">MkCTimeval</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">ptval</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-identifier">throwErrnoIfMinus1_</span><span> </span><span class="hs-string">&quot;gettimeofday&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">gettimeofday</span><span> </span><span class="hs-identifier">ptval</span><span> </span><span class="hs-identifier">nullPtr</span><span>
</span><span id="line-32"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">ptval</span><span>
</span><span id="line-33"></span><span>    </span><span class="hs-special">)</span><span class="hs-cpp">

#endif
</span></pre></body></html>